#include <iostream>
#include <vector>
using namespace std;

int n, m;
vector<int> path;

void dfs(int pos, int begin)
{
	if (pos > m)
	{
		for (auto v : path)
			cout << v << " ";
		cout << endl;
		return;
	}

	for (int i = begin; i <= n; i++)
	{
		path.push_back(i);
		dfs(pos + 1, i + 1);
		path.pop_back();	// 清空现场
	}
}

void dfs1(int begin)
{
	if (path.size() == m)
	{
		for (auto v : path)
			cout << v << " ";
		cout << endl;
		return;
	}

	for (int i = begin; i <= n; i++)
	{
		path.push_back(i);
		dfs1(i + 1);
		path.pop_back();	// 清空现场
	}
}

int main()
{
	cin >> n >> m;

	// dfs(1, 1);
	dfs1(1);

	return 0;
}